import {cardCache} from "nc-lightapp-front";
import { DOCLIST } from "../../../../common/constant";
import { byPkorgFiter, fiterDefdoc, fiterFrkm } from "../../../../common/util/fiterUtils";
import { CARD } from "../../constant";
let {getDefData } = cardCache;
/**
* @description: 表体编辑前事件
* @param: moduleId 区域编码
* @param: key 当前字段编码
* @return: 布尔 true表示可编辑
*/
export function beforeTableEvent(props, moduleId, key, value, index, record, status) {
        
        if(key == 'acc' ){
            let pk_org = props.form.getFormItemsValue('card_head', 'pk_org').value;
            let pk_accountingbook = getDefData("accbook","accbook");
            let fiterType = DOCLIST.qtsrdf;
            fiterFrkm(props, moduleId, key, pk_org, pk_accountingbook, fiterType);
            
        }else if(key == 'bdef1'){//管理科目

            //获取表单中的利润中心名称
            // let center = props.form.getFormItemsValue(CARD.form_id, 'center').value;
            // let where = "def1 in (select pk_org from org_orgs where dr=0 and name in (select name from org_orgs where pk_org='"+center+"')) and def7='Y'";
            // fiterDefdoc(props, moduleId, key, where);
            
        }else if(key == 'cutsup'){
            //客商
            
            let data = null;
            let value = props.form.getFormItemsValue(CARD.form_id, 'pk_org');
            if(value.value != ''){
                    data = value;
            }

            let pk_org = value.value;

            if(data != null){
                byPkorgFiter(props, moduleId, key, pk_org, false);//客商
            }
        }
           
        return true;  
       
}
